<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ taglib uri="/browserTag" prefix="brow"%>
<%@ include file="/systeminfo/init_wev8.jsp"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page" />
<jsp:useBean id="wtci" class="weaver.workflow.workflow.WorkTypeComInfo" scope="page" />
<jsp:useBean id="wci" class="weaver.workflow.workflow.WorkflowComInfo" scope="page"/>
<jsp:useBean id="rci" class="weaver.hrm.resource.ResourceComInfo" scope="page" />
<jsp:useBean id="jci" class="weaver.hrm.job.JobTitlesComInfo" scope="page" />
<jsp:useBean id="DepartmentComInfo" class="weaver.hrm.company.DepartmentComInfo" scope="page"/>
<jsp:useBean id="SubCompanyComInfo" class="weaver.hrm.company.SubCompanyComInfo" scope="page"/>
<jsp:useBean id="flowTypeTimeAnalyseSort" class="weaver.workflow.WorkflowReportCronJob" scope="page" />
<jsp:useBean id="NodeOverTimeInfo" class="weaver.workflow.node.NodeOverTimeInfo" scope="page" />
<%
	int pageSize = 10;
	int totalNum = 0; // 总条数
	int totalPageNum = 0; // 总页数
	int pageNum = Util.getIntValue(Util.null2String(request.getParameter("pageNum")), 1); // 当前页数
	int changePageNum = Util.getIntValue(Util.null2String(request.getParameter("changePageNum")), -1);
	if(0 == changePageNum) {
		pageNum = 1;
	}else if(1 == changePageNum) {
		pageNum--;
	}else if(2 == changePageNum) {
		pageNum++;
	}

	String isSearch = Util.null2String(request.getParameter("isSearch")); // 第一次打开页面不显示数据
    isSearch = "1";

	ArrayList requestidMaps = new ArrayList();
	if("1".equals(isSearch)) {
		String sqlFrom = " from uf_bill_deliver a ";
		String sql = " where a.presentation_date = CONVERT(varchar(10),GETDATE(),23) ";


		String sql1 = "select count(*) count " + sqlFrom + sql;
		//out.println(sql1);
		rs.executeSql(sql1);
		if(rs.next()) {
			totalNum= rs.getInt("count");
		}
		if(totalNum > 0) {
			totalPageNum = (totalNum % pageSize > 0) ? (totalNum / pageSize) + 1 : (totalNum / pageSize);
			if(3 == changePageNum) {
				pageNum = totalPageNum;
			}
		}
		if(pageNum > totalPageNum) {
			pageNum = totalPageNum;
		}
		if(pageNum <= 0) {
			pageNum = 1;
		}

		sql1 = "select * from (select ROW_NUMBER() OVER(Order by a.presentation_time desc) rowNumber,a.* " + sqlFrom + sql
				+ ") t where rowNumber > " + ((pageNum - 1) * pageSize) + " and rowNumber <= " + (pageNum * pageSize);

		sql1 += " order by presentation_time desc";
 		//out.println(sql1);
		rs.executeSql(sql1);
		while(rs.next()) {
			int rowNumber = Util.getIntValue(rs.getString("rowNumber"));
		    int requestid = Util.getIntValue(rs.getString("requestid"));


			HashMap requestidMap = new HashMap();
			requestidMap.put("rowNumber",rowNumber);
			requestidMap.put("requestid", requestid);
			requestidMap.put("requestmark", Util.null2String(rs.getString("requestmark")));
			requestidMap.put("requestname", Util.null2String(rs.getString("requestname")));
			requestidMap.put("creater", Util.null2String(rs.getString("creater")));
			requestidMap.put("departmentid", Util.null2String(rs.getString("departmentid")));
			requestidMap.put("subcompanyid1", Util.null2String(rs.getString("subcompanyid1")));
			requestidMap.put("presentation_date", Util.null2String(rs.getString("presentation_date")));
			requestidMap.put("presentation_time", Util.null2String(rs.getString("presentation_time")));
			requestidMap.put("receiver", Util.null2String(rs.getString("receiver")));

			requestidMap.put("rowNum", rs1.getCounts());

			requestidMaps.add(requestidMap);
		}
	}

	String titlename = "";
%>
<HTML>
<HEAD>
	<LINK REL=stylesheet type=text/css HREF=/css/Weaver_wev8.css>
	<SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
</head>
<BODY>
<%@ include file="/systeminfo/TopTitle_wev8.jsp"%>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp"%>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp"%>
<!--    <table id="topTitle" cellpadding="0" cellspacing="0">
	<tr>
		<td>
		</td>
		<td class="rightSearchSpan">
			<input type="button" value="备用按钮" class="e8_btn_top" onclick="//newImplement()" />
			<input type="button" value="备用按钮" class="e8_btn_top" onclick="" />
			<input type="button" value="备用按钮" class="e8_btn_top" onclick="" />
			<span title="<%//=SystemEnv.getHtmlLabelName(23036, user.getLanguage()) %>" class="cornerMenu"></span>
		</td>
	</tr>
</table>-->
<form action="/wtoip/finance/reimbursement/QuickReceipt.jsp" method="post" name="QuickReceiptForm" id="QuickReceiptForm">
	<input type="hidden" name="isSearch" id="isSearch" value="1" />
	<wea:layout type="4col">
		<wea:group context="" attributes="{'groupDisplay':'none'}">
			<wea:item><TABLE class="ListStyle" cellspacing="1" style="width: 150%">
				<TR>
					<TD><br><br><br></TD>
				</TR>
			</TABLE></wea:item>
		</wea:group>
		<wea:group context="" attributes="{'groupDisplay':'none'}">
			<wea:item attributes="{'isTableList':'true'}">
				<TABLE class="ListStyle" cellspacing="1" style="width: 100%">
					<TR class="header">
						<TH width="5%">序号</TH>
						<TH width="10%">流程编号</TH>
						<TH width="15%">流程标题</TH>
						<TH width="10%">创建人</TH>
						<TH width="10%">所属公司</TH>
						<TH width="10%">所属部门</TH>
						<TH width="10%">交单日期</TH>
						<TH width="10%">交单时间</TH>
						<TH >收单人</TH>
					</TR>
					<%
						for(int i = 0; i < requestidMaps.size(); i++) {

						    HashMap requestidMap = (HashMap) requestidMaps.get(i);
							int requestid = (Integer) requestidMap.get("requestid");
							int rowNum = (Integer) requestidMap.get("rowNum");
							if(rowNum <= 0) {
								rowNum = 1;
							}
							String userId = Util.null2String(requestidMap.get("creater"));
							String receiverId = Util.null2String(requestidMap.get("receiver"));

					%>
					<TR class="DataDark">
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(requestidMap.get("rowNumber")) %></TD>
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(requestidMap.get("requestmark")) %></TD>
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(requestidMap.get("requestname")) %></TD>
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(rci.getResourcename(userId)) %></TD>
						<TD rowspan="<%=rowNum %>"><%=SubCompanyComInfo.getSubCompanyname(Util.null2String(requestidMap.get("subcompanyid1")))%></TD>
						<TD rowspan="<%=rowNum %>"><%=DepartmentComInfo.getDepartmentname(Util.null2String(requestidMap.get("departmentid")))%></TD>
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(requestidMap.get("presentation_date")) %></TD>
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(requestidMap.get("presentation_time")) %></TD>
						<TD rowspan="<%=rowNum %>"><%=Util.null2String(rci.getResourcename(receiverId)) %></TD>
					</TR>
					<%	} %>
				</TABLE>
				<% if("1".equals(isSearch) && requestidMaps.size() > 0) { %>
				<div align="left" style="width: 100%">
					<% if(1 != pageNum) { %>
					<a href="javascript:changePageNum(0);">首页</a>
					<a href="javascript:changePageNum(1);">上一页</a>
					<% } %>
					<% if(totalPageNum > 0 && totalPageNum != pageNum) { %>
					<a href="javascript:changePageNum(2);">下一页</a>
					<a href="javascript:changePageNum(3);">末页</a>
					<% } %>
					<span>
							第<input type="text" name="pageNum" id="pageNum" maxlength="9" value="<%=pageNum %>" onKeyPress="ItemCount_KeyPress()"
									onBlur='<%="checkcount1(this);if(this.value < 0) {this.value = \"" + pageNum + "\";}" %>' style="width: 50px !important;" />页
						</span>
					<span>共<%=totalPageNum %>页</span>
					<span>共<%=totalNum %>条</span>
					<input type="hidden" name="changePageNum" id="changePageNum" value="" />
				</div>
				<% } %>
			</wea:item>
		</wea:group>
	</wea:layout>
</form>
</body>
<SCRIPT language="javascript" src="/js/datetime_wev8.js"></script>
<SCRIPT language="javascript" src="/js/selectDateTime_wev8.js"></script>
<SCRIPT language="javascript" src="/js/JSDateTime/WdatePicker_wev8.js"></script>
<script type="text/javascript">
    function doImplement() {
        jQuery("#isSearch").val(1);
        QuickReceiptForm.submit();
    }
    function changePageNum(index) {
        jQuery("#changePageNum").val(index);
        doImplement();
    }
    function newImplement(){
        window.open ("ImplementBill.jsp", "newwindow", "height=400, width=400, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")
	}
</script>
</html>
